package nl.sodeso.cubicex.command.action;

import java.util.Map;

import nl.sodeso.cubicex.CubicExBaseTestCase;

import org.cubictest.selenium.custom.IElementContext;

import com.thoughtworks.selenium.Selenium;

/**
 * Replaces the <code>selectWindow</code> command of SeleniumIDE
 * 
 * @author c.beaujoin
 * @since 0.0.4
 */
public class FireSelectWindowById extends CubicExBaseTestCase {

	/**
	 * {@inheritDoc}
	 */
	public void executeTest(final Map<String, String> arguments, final IElementContext context, final Selenium selenium) throws Exception {
		
		// Retrieve the parameters.
		final Integer _level = getArgValueAsInteger();
		
		String[] windowsName = selenium.getAllWindowNames();
		selenium.selectWindow(windowsName[_level.intValue()]);
	}
}
